package org.bright.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.bright.entity.User;
import org.bright.mapper.UserMapper;
import org.bright.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> getUsers(String name,Integer age) {
        System.out.println(" 路过service ");
        return userMapper.getUsers(name,age);
    }

    @Override
    public int deleteById(int id) {
        return userMapper.deleteById(id);
    }

    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public PageInfo<User> getPage(String name, Integer age, Integer pageNum) {
        PageHelper.startPage(pageNum,3);
        List<User> users = userMapper.getUsers(name, age);
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        return userPageInfo;
    }
}
